home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / socket.man < prev    next >
Encoding:
Text File  |  1989-01-12  |  7.1 KB  |  199 lines

  1.  
  2.  
  3.  
  4. SOCKET                C Library Procedures                 SOCKET
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      socket - create an endpoint for communication
  10.  
  11. SSYYNNOOPPSSIISS
  12.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  13.      ##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>
  14.  
  15.      ss == ssoocckkeett((ddoommaaiinn,, ttyyppee,, pprroottooccooll))
  16.      iinntt ss,, ddoommaaiinn,, ttyyppee,, pprroottooccooll;;
  17.  
  18. DDEESSCCRRIIPPTTIIOONN
  19.      _S_o_c_k_e_t creates an endpoint for communication and returns a
  20.      descriptor.
  21.  
  22.      The _d_o_m_a_i_n parameter specifies a communications domain
  23.      within which communication will take place; this selects the
  24.      protocol family which should be used.  The protocol family
  25.      generally is the same as the address family for the
  26.      addresses supplied in later operations on the socket.  These
  27.      families are defined in the include file <_s_y_s/_s_o_c_k_e_t._h>.
  28.      The currently understood formats are
  29.  
  30.           PF_UNIX     (UNIX internal protocols),
  31.           PF_INET     (ARPA Internet protocols),
  32.           PF_NS       (Xerox Network Systems protocols), and
  33.           PF_IMPLINK  (IMP "host at IMP" link layer).
  34.  
  35.      The socket has the indicated _t_y_p_e, which specifies the
  36.      semantics of communication.  Currently defined types are:
  37.  
  38.           SOCK_STREAM
  39.           SOCK_DGRAM
  40.           SOCK_RAW
  41.           SOCK_SEQPACKET
  42.           SOCK_RDM
  43.  
  44.      A SOCK_STREAM type provides sequenced, reliable, two-way
  45.      connection based byte streams.  An out-of-band data
  46.      transmission mechanism may be supported.  A SOCK_DGRAM
  47.      socket supports datagrams (connectionless, unreliable mes-
  48.      sages of a fixed (typically small) maximum length).  A
  49.      SOCK_SEQPACKET socket may provide a sequenced, reliable,
  50.      two-way connection-based data transmission path for
  51.      datagrams of fixed maximum length; a consumer may be
  52.      required to read an entire packet with each read system
  53.      call.  This facility is protocol specific, and presently
  54.      implemented only for PF_NS.  SOCK_RAW sockets provide access
  55.      to internal network protocols and interfaces.  The types
  56.      SOCK_RAW, which is available only to the super-user, and
  57.      SOCK_RDM, which is planned, but not yet implemented, are not
  58.      described here.
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 23, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SOCKET                C Library Procedures                 SOCKET
  71.  
  72.  
  73.  
  74.      The _p_r_o_t_o_c_o_l specifies a particular protocol to be used with
  75.      the socket.  Normally only a single protocol exists to sup-
  76.      port a particular socket type within a given protocol fam-
  77.      ily.  However, it is possible that many protocols may exist,
  78.      in which case a particular protocol must be specified in
  79.      this manner.  The protocol number to use is particular to
  80.      the "communication domain" in which communication is to take
  81.      place; see _p_r_o_t_o_c_o_l_s(3N).
  82.  
  83.      Sockets of type SOCK_STREAM are full-duplex byte streams,
  84.      similar to pipes.  A stream socket must be in a _c_o_n_n_e_c_t_e_d
  85.      state before any data may be sent or received on it.  A con-
  86.      nection to another socket is created with a _c_o_n_n_e_c_t(2) call.
  87.      Once connected, data may be transferred using _r_e_a_d(2) and
  88.      _w_r_i_t_e(2) calls or some variant of the _s_e_n_d(2) and _r_e_c_v(2)
  89.      calls.  When a session has been completed a _c_l_o_s_e(2) may be
  90.      performed.  Out-of-band data may also be transmitted as
  91.      described in _s_e_n_d(2) and received as described in _r_e_c_v(2).
  92.  
  93.      The communications protocols used to implement a SOCK_STREAM
  94.      insure that data is not lost or duplicated.  If a piece of
  95.      data for which the peer protocol has buffer space cannot be
  96.      successfully transmitted within a reasonable length of time,
  97.      then the connection is considered broken and calls will
  98.      indicate an error with -1 returns and with ETIMEDOUT as the
  99.      specific code in the global variable errno.  The protocols
  100.      optionally keep sockets "warm" by forcing transmissions
  101.      roughly every minute in the absence of other activity.  An
  102.      error is then indicated if no response can be elicited on an
  103.      otherwise idle connection for a extended period (e.g. 5
  104.      minutes).  A SIGPIPE signal is raised if a process sends on
  105.      a broken stream; this causes naive processes, which do not
  106.      handle the signal, to exit.
  107.  
  108.      SOCK_SEQPACKET sockets employ the same system calls as
  109.      SOCK_STREAM sockets.  The only difference is that _r_e_a_d(2)
  110.      calls will return only the amount of data requested, and any
  111.      remaining in the arriving packet will be discarded.
  112.  
  113.      SOCK_DGRAM and SOCK_RAW sockets allow sending of datagrams
  114.      to correspondents named in _s_e_n_d(2) calls.  Datagrams are
  115.      generally received with _r_e_c_v_f_r_o_m(2), which returns the next
  116.      datagram with its return address.
  117.  
  118.      An _f_c_n_t_l(2) call can be used to specify a process group to
  119.      receive a SIGURG signal when the out-of-band data arrives.
  120.      It may also enable non-blocking I/O and asynchronous notifi-
  121.      cation of I/O events via SIGIO.
  122.  
  123.      The operation of sockets is controlled by socket level
  124.      _o_p_t_i_o_n_s.  These options are defined in the file
  125.      <_s_y_s/_s_o_c_k_e_t._h>.  _S_e_t_s_o_c_k_o_p_t(2) and _g_e_t_s_o_c_k_o_p_t(2) are used to
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 23, 1986                          2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SOCKET                C Library Procedures                 SOCKET
  137.  
  138.  
  139.  
  140.      set and get options, respectively.
  141.  
  142. RREETTUURRNN VVAALLUUEE
  143.      A -1 is returned if an error occurs, otherwise the return
  144.      value is a descriptor referencing the socket.
  145.  
  146. EERRRROORRSS
  147.      The _s_o_c_k_e_t call fails if:
  148.  
  149.      [EPROTONOSUPPORT]   The protocol type or the specified pro-
  150.                          tocol is not supported within this
  151.                          domain.
  152.  
  153.      [EMFILE]            The per-process descriptor table is
  154.                          full.
  155.  
  156.      [ENFILE]            The system file table is full.
  157.  
  158.      [EACCESS]           Permission to create a socket of the
  159.                          specified type and/or protocol is
  160.                          denied.
  161.  
  162.      [ENOBUFS]           Insufficient buffer space is available.
  163.                          The socket cannot be created until suf-
  164.                          ficient resources are freed.
  165.  
  166. SSEEEE AALLSSOO
  167.      accept(2), bind(2), connect(2), getsockname(2), get-
  168.      sockopt(2), ioctl(2), listen(2), read(2), recv(2),
  169.      select(2), send(2), shutdown(2), socketpair(2), write(2)
  170.      ``An Introductory 4.3BSD Interprocess Communication
  171.      Tutorial.'' (reprinted in UNIX Programmer's Supplementary
  172.      Documents Volume 1, PS1:7) ``An Advanced 4.3BSD Interprocess
  173.      Communication Tutorial.'' (reprinted in UNIX Programmer's
  174.      Supplementary Documents Volume 1, PS1:8)
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Sprite v1.0               May 23, 1986                          3
  196.  
  197.  
  198.  
  199.